-
Notifications
You must be signed in to change notification settings - Fork 61
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix no-setup-in-describe to allow Mocha suite config #209
Fix no-setup-in-describe to allow Mocha suite config #209
Conversation
This rule will now allow `this.timeout();`, `this.slow();`, and `this.retries();` in describe blocks, since they're configuration for the suite and not setup. Fixes lo1tuma#208.
@@ -19,10 +19,16 @@ ruleTester.run('no-setup-in-describe', rule, { | |||
'it("", function () { a[b]; })', | |||
'it("", function () { a["b"]; })', | |||
'describe("", function () { it(); })', | |||
'describe("", function () { this.slow(1); it(); })', | |||
'describe("", function () { this.timeout(1); it(); })', | |||
'describe("", function () { this.retries(1); it(); })', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you add one test case with a computed member expression? E.g. this['retries'](1);
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My change to the rule doesn't allow for that form of the expression, so I added this to the invalid test cases, but lmk if you would rather I add support for that form in the rule!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMHO we should handle this case as well. There is already a function for that in ast utils: getPropertyName()
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All set!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Thank you!
This rule will now allow
this.timeout();
,this.slow();
, andthis.retries();
in describe blocks, since they're configuration forthe suite and not setup.
Fixes #208.